<template>
<div>
  <el-button type="primary" @click="toggleSelection()">取消选择</el-button>
  <el-table
      ref="multipleTable"
      @selection-change="handleSelectionChange"
      :data="tableData.slice((currentPage-1)*PageSize,currentPage*PageSize)"
      style="width: 100%">
    <el-table-column
        type="selection"
        width="55">
    </el-table-column>
    <el-table-column
        prop="time"
        label="日期"
        width="180">
    </el-table-column>
    <el-table-column
        prop="stuName"
        label="姓名"
        width="180">
    </el-table-column>
    <el-table-column
        prop="teacherName"
        label="咨询师">
    </el-table-column>
    <el-table-column label="操作">
      <template #default="scope">
        <el-button size="small" type="primary" v-if="scope.row.visitStatus === 1" @click="handleManage(scope.$index, scope.row)"
        >安排</el-button
        >
        <el-button size="small" @click="handleEdit(scope.$index, scope.row)"
        >编辑</el-button
        >
        <el-button
            size="small"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
        >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
  <div class="block">
    <el-pagination
        :hide-on-single-page="value"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="PageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.length">
    </el-pagination>
  </div>
</div>
</template>

<script>
import {getConsult} from "../../api/consult";
import {getSpareTeacherByTimeId} from "../../api/user";
import {ElMessage} from "element-plus";
import {deleteById} from "../../api/firstLog";

export default {
  name: "consultManagement",
  data(){
    return {
      tableData: [
        {
          teacherName: '',
          consult: {},
          stuName: '',
          time: '',
        }
      ],
      value:true,
      PageSize:10,
      currentPage:1,
    }
  },
  created() {
    this.getDate()
  },
  methods: {
    getDate(){
      getConsult().then(res=>{
        if(res.code === 1){
          this.tableData = res.data
        }
      })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      console.log(this.multipleSelection)
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleManage(index,row){
      console.log(row)
    },
    handleEdit(index,row){
      console.log(row)
    },
    handleDelete(index,row){
      console.log(row.id)
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
  }
}
</script>

<style scoped>

</style>